﻿@{   
    Layout = null;
}
<div id="baidumap" style="width: 100%; height: 300px;"></div>
<input type="hidden" id="lo" value="0.00" />
<input type="hidden" id="la" value="0.00" />
<script type="text/javascript">   
    setTimeout(function(){    
        var map = new BMap.Map("baidumap");
        var point = new BMap.Point(@ViewBag.Lo,@ViewBag.La);
        map.centerAndZoom(point, 15);
        map.addControl(new BMap.NavigationControl());
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);        
        marker.setTitle("拖动修改位置");
        marker.enableDragging();

        marker.addEventListener("click", function(e) {
            p = e.point;                     
            document.getElementById("la").value = p.lat;
            document.getElementById("lo").value = p.lng;
            map.centerAndZoom(p,15);
        });
        marker.addEventListener("dragstart", function(e) {
            map.closeInfoWindow()
        });
             

        marker.addEventListener("dragend", function(e) {
            p = e.point;            
            marker = new BMap.Marker(p);            
            document.getElementById("la").value = p.lat;
            document.getElementById("lo").value = p.lng;
            map.centerAndZoom(p,15);
        });

    },1000);
</script>
